//
//  SWNewHomeViewController.m
//  DataTransfer
//
//  Created by 宋润理 on 2023/12/22.
//  Copyright © 2023 James. All rights reserved.
//

#import "SWNewHomeViewController.h"
#import "SWScanTextViewController.h"
#import "LFViewController.h"
#import "HomeViewController.h"
#import "AboutViewController.h"

#define scaleValueForIphone6(x)         (x * (kScreenWidth/375))

@interface SWNewHomeViewController ()

@end

@implementation SWNewHomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"快传宝换机";
    
    
    
    
    [self setRightItemWithTitle:@"关于" selector:@selector(jumpAbout) color:MainThemeColor];
    UIImageView *mainImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Apple1024"]];
    mainImage.contentMode = UIViewContentModeScaleAspectFit;
    [self.view addSubview:mainImage];
    [mainImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@(25));
        make.centerX.equalTo(@(0));
        make.width.height.equalTo(@(70));
    }];
    
    UILabel *title = [UILabel new];
    title.text = @"刚买的手机？\n\n 担心不是正版？\n\n 三步帮你解决！";
    title.textAlignment = NSTextAlignmentCenter;
    title.textColor = MainThemeColor;
    title.font = [UIFont systemFontOfSize:20];
    title.numberOfLines = 0;
    [self.view addSubview:title];
    [title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(mainImage.mas_bottom).offset(scaleValueForIphone6(20));
        make.left.equalTo(self.view).offset(50);
        make.right.equalTo(@(-50));
    }];
    
    UIButton *scan = [UIButton buttonWithType:UIButtonTypeCustom];
    scan.backgroundColor = MainThemeColor;
    [scan setTitle:@"扫描包装上的序列号并验证" forState:UIControlStateNormal];
    [scan setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    scan.layer.cornerRadius = 10;
    scan.layer.masksToBounds = YES;
    [scan addTarget:self action:@selector(jumpScan) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:scan];
    [scan mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(title);
        make.top.equalTo(title.mas_bottom).offset(scaleValueForIphone6(40));
        make.height.equalTo(@(50));
    }];
    
    UIImageView *arrow1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow_down"]];
    [self.view addSubview:arrow1];
    [arrow1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(@(0));
        make.top.equalTo(scan.mas_bottom).offset(scaleValueForIphone6(10));
    }];
    
    UIButton *deviceInfo = [UIButton buttonWithType:UIButtonTypeCustom];
    deviceInfo.backgroundColor = MainThemeColor;
    [deviceInfo setTitle:@"检查设备信息" forState:UIControlStateNormal];
    [deviceInfo setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    deviceInfo.layer.cornerRadius = 10;
    deviceInfo.layer.masksToBounds = YES;
    [deviceInfo addTarget:self action:@selector(jumpDevice) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:deviceInfo];
    [deviceInfo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(scan);
        make.top.equalTo(arrow1.mas_bottom).offset(scaleValueForIphone6(10));
        make.height.equalTo(@(50));
    }];
    
    UIImageView *arrow2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow_down"]];
    [self.view addSubview:arrow2];
    [arrow2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(@(0));
        make.top.equalTo(deviceInfo.mas_bottom).offset(scaleValueForIphone6(10));
    }];
    
    UIButton *transfer = [UIButton buttonWithType:UIButtonTypeCustom];
    transfer.backgroundColor = MainThemeColor;
    [transfer setTitle:@"数据传输" forState:UIControlStateNormal];
    [transfer setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    transfer.layer.cornerRadius = 10;
    transfer.layer.masksToBounds = YES;
    [transfer addTarget:self action:@selector(jumpTransfer) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:transfer];
    [transfer mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(deviceInfo);
        make.top.equalTo(arrow2.mas_bottom).offset(scaleValueForIphone6(10));
        make.height.equalTo(@(50));
    }];
}

- (void)jumpScan {
    SWScanTextViewController *vc = [SWScanTextViewController new];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)jumpDevice {
    LFViewController *vc = [LFViewController new];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)jumpTransfer {
    HomeViewController *vc = [HomeViewController new];
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)jumpAbout {
    AboutViewController *vc = [AboutViewController new];
    [self.navigationController pushViewController:vc animated:YES];
}
@end
